﻿
/// <summary>
/// 小游戏
/// </summary>
using System.Diagnostics;
//计算代码运行的时间
Stopwatch stopWatch = new Stopwatch();
//开始计时
stopWatch.Start();
//定义错误次数，游戏次数
int error = 0;
//生成随机变量
Random random = new Random();
//游戏次数随机
int n = random.Next(5, 10);
for (int i = 0; i < n; i++)
{
    //开始前清屏
    Console.Clear();
    //提示的字符范围是A-Z，a-z
    char key;
    do { 
        key = (char)random.Next(65,122); 
    }while (key >= 'Z' && key <= 'a');
    Console.WriteLine(key);
    //用户输入
    char input=Console.ReadKey().KeyChar;
    //判断输入是否和提示一致
    if (input != key)
        error++;
}
//计时结束
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;
double time=ts.TotalMilliseconds;   
Console.WriteLine($"游戏运行时间为{time}毫秒");
Console.WriteLine($"游戏进行了{n}轮");
Console.WriteLine($"您的错误次数为{error}次");



